# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=broot
pkgver=1.14.0
pkgrel=1
pkgdesc="New way to see and navigate directory trees"
url="https://github.com/Canop/broot"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"  # limited by rust/cargo
license="MIT"
makedepends="
	cargo
	libgit2-dev
	libxcb-dev
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/Canop/broot/archive/v$pkgver/broot-$pkgver.tar.gz
	image-features.patch
	syntect-without-onig.patch
	"

export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL=2
export CARGO_PROFILE_RELEASE_PANIC="abort"

prepare() {
	default_prepare

	# Omit --locked to update Cargo.lock after patching Cargo.toml.
	cargo fetch
}

build() {
	cargo build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -D -m755 target/release/broot -t "$pkgdir"/usr/bin/
	install -D -m644 man/page "$pkgdir"/usr/share/man/man1/broot.1

	cd "$(find target/release -name broot.bash -exec dirname {} \; -quit)"

	install -D -m644 broot.bash "$pkgdir"/usr/share/bash-completion/completions/broot
	install -D -m644 _broot -t "$pkgdir"/usr/share/zsh/site-functions/
	install -D -m644 broot.fish -t "$pkgdir"/usr/share/fish/completions/
}

sha512sums="
85c33ff7e541c7dda8beccad0969b7788513bba1ae550bc1cebe238295673dfcd42d1f86a0f7aa4619df31420be1bff3cfbb84814cb30ac23cd19d0376786e92  broot-1.14.0.tar.gz
4279757e6e44d797ed9cae545bf8c1d56a7e4d7cf66c453b91e313f57e20c2a22064274c4e9039ef73f2f1f1500699dbdfe8907b52752f65ea056f22238faf66  image-features.patch
c2dc430f92ed76ab1aa97034e4c54e3039cb7a093d9bd8f81daaea604e135bb20b6cebd58721c18c13c7107a774c2e1aceb0a25466b2926775065bae5e958ad1  syntect-without-onig.patch
"
